<template>
    <div v-loading="loading"> 
        <el-row>
            <!--扫码区域-->
            <el-col :span="24">
                <div class="grid-content bg-purple-dark">
                    <el-input  v-model="scanValue" size="mini" style="width:150px" placeholder="请输入缓存箱/托盘码" 
                    @keyup.enter.native="scan($event)"></el-input>
                </div>
            </el-col>
             <!--缓存箱区域-->
            <el-col :span="12">
                <span>缓存箱编码:<Strong>{{ workbinCode }}</Strong></span>
                <ul class="pbox">
                    <li  class="box infinite-list-item" v-for="(hcxinfo,index) in hcxinfos" :key="index">
                        <p><span>条码:</span><span class="p-margin"><strong>{{hcxinfo.barcode}}</strong></span></p>
                        <p><span>工作包编号:</span><span class="p-margin"><strong>{{hcxinfo.packageCode}}</strong></span></p>
                        <p><span>AO编号:</span><span class="p-margin"><strong>{{hcxinfo.aoCode}}</strong></span></p>
                        <p><span>所在托盘:</span><span class="p-margin"><strong>{{ hcxinfo.toolCode }}</strong></span></p>
                        <p><span>图号:</span><span class="p-margin"><strong>{{hcxinfo.itemCode}}</strong></span></p>
                        <p><span>型号:</span><span class="p-margin"><strong>{{hcxinfo.mProductNumber}}</strong></span></p>
                        <p><span>质量编号:</span><span class="p-margin"><strong>{{hcxinfo.qualityCode}}</strong></span></p>
                        <p><span>所属单位:</span><span class="p-margin"><strong>{{hcxinfo.invShop}}</strong></span></p>
                        <p v-if="hcxinfo.receiveRemark"><span>是否有备注:</span><span class="p-margin"><el-tag type="success" size="small" style="cursor:pointer" @click="openRemarkView(hcxinfo)">有备注</el-tag></span></p>
                        <p v-else="hcxinfo.receiveRemark"><span>是否有备注:</span><span class="p-margin"><el-tag type="danger" size="small" style="cursor:pointer" @click="openRemarkView(hcxinfo)">无备注</el-tag></span></p>
                        <p style="margin-top:5px"> 待分拣数量：<span style="margin-left: 3px;"><el-input size="mini" style="width:80px;font-size:1.2em" v-model="hcxinfo.matchQty"></el-input></span></p>
                        <p style="margin-top:5px">是否带证：  
                            <el-select size="mini" style="width:100px" v-model="hcxinfo.isPaper" placeholder="请选择">
                                <el-option  v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </p>
                        <p><span>确认状态:</span><span ref="materialBox"><strong>未确认</strong></span></p>
                        <p>
                            <!--<el-button size="mini" type="primary" style="margin:5px 3px" @click="openRightWorkbinBox(index)">矫正缓存箱数据</el-button>-->
                            <el-button size="mini" type="primary" style="margin:5px 3px" @click="showWorkbinView(hcxinfo)">补叫箱子</el-button>
                            <el-button size="mini" type="primary" style="margin:5px 3px" @click="openReplaceView(hcxinfo)">更换物料</el-button>
                        </p>
                            <!--叶博添加修改备注-->
                            <el-dialog  title="修改备注" :visible.sync="hcxbox.dialog.dialogVisible"  width="50%" :before-close="hxcDialogHandleClose">
                                <el-input type="textarea" v-model="updateRemark"></el-input>
                                <span slot="footer" class="dialog-footer">
                                    <el-button @click="hcxbox.dialog.dialogVisible = false">取 消</el-button>
                                    <el-button type="primary" @click="saveRemark">确 定</el-button>
                                </span>
                            </el-dialog>
                    </li>
                </ul>
            </el-col>
            <!--托盘区域-->
            <el-col :span="12">
                <span v-if="toolCode != ''"><el-button type="text" @click="searchMaterialInfo()">工作包编码:<Strong>{{ toolCode }}</Strong></el-button>
                </span>
                <span v-else>工作包编码:<Strong>{{ toolCode }}</Strong>
                </span>
                <ul class="pbox">
                    <li  class="box infinite-list-item" v-for="toolinfo in scanMaterialBoxs">
                        <p><span>条码:</span><span><strong>{{toolinfo.barcode}}</strong></span></p>
                        <p><span>AO编号:</span><span><strong>{{toolinfo.aoCode}}</strong></span></p>
                        <p><span>图号:</span><span><strong>{{toolinfo.itemCode}}</strong></span></p>
                        <p><span>质量编号:</span><span><strong>{{toolinfo.qualityCode}}</strong></span></p>
                        <p><span>配套数量:</span><span><strong>{{toolinfo.matchQty}}</strong></span></p>
                    </li>
                </ul>
            </el-col>
        </el-row>
        <!--更换物料抽屉-->
        <div>
            <el-drawer title="物料替换" size="75%" :visible.sync="drawer.drawer" :direction="drawer.direction" :before-close="handleClose">
            <el-button style="margin-left:5px;margin-bottom:3px" type="primary" size="mini" @click="saveReplaceData">替换</el-button>  
            <el-row>
                <el-col :span="8">
                <slot>已配套物料</slot>
                <el-table :data="drawer.leftdata" border height=500  >
                    <el-table-column prop="itemCode" label="图号" width="180" resizable> </el-table-column>
                    <el-table-column prop="qualityCode" label="质量编号" width="100" resizable> </el-table-column>
                    <el-table-column prop="matchQty" label="配套数量" resizable> </el-table-column>
                </el-table>
                </el-col>
                <el-col :span="16">
                <slot>可配套物料</slot>
                <el-table :data="drawer.rightData" border height=500 >
                    <el-table-column prop="itemCode" label="图号" width="180" resizable > </el-table-column>
                    <el-table-column prop="qualityCode" label="质量编号" width="100" resizable> </el-table-column>
                    <el-table-column prop="useLimitInfo" label="限用信息" width="100" resizable :show-overflow-tooltip="true"> </el-table-column>
                    <el-table-column prop="itemQty" label="库存数量" resizable> </el-table-column>
                    <el-table-column prop="replaceQty" label="替换数量" resizable>
                    <template slot-scope="scope">
                        <input type="text" style="width:80px;" v-model="drawer.rightData[scope.$index].replaceQty"/>
                    </template>
                    </el-table-column>
                </el-table>
                </el-col>
            </el-row>
            </el-drawer>
        </div>
        <div>
            <el-drawer title="物料信息" size="75%" height="500" :visible.sync="drawer2.drawer" :direction="drawer2.direction" :before-close="handleClose2" :append-to-body="drawer2.drawer">
                <el-row>
                    <el-col :span="24">
                        <el-table :data="drawer2.materialTableData" border height=440  >
                            <el-table-column type="index" label="序号" width="50" :show-overflow-tooltip="true"> </el-table-column>
                            <el-table-column property="state" label="配套状态" width="90" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="isSort" label="分拣状态" width="90" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="requiredDeliveryTime" label="日计划时间" width="170" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="itemCode" label="图号" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="qualityCode" label="质量编号" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="aoCode" label="AO编码" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="packageCode" label="工作包编码" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="productCode" label="机型" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="batchNo" label="批次" width="70" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="startPlaneNo" label="架次" width="70" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="itemName" label="物料名称" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="itemQty" label="需求数量" width="90" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="matchQty" label="配套数量" width="90" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="barCode" label="条码号" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="workbinCode" label="缓存箱编码" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="repartAss" label="装配图号" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="artChangeType" label="工艺更改类型" width="150" :show-overflow-tooltip="true"></el-table-column>
                            <el-table-column property="mesCheckQualiticationId" label="合格证" v-if="false"></el-table-column>
                        </el-table>
                        
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page.currentPage"
                        :page-sizes="[50,100, 200, 300, 400]" :page-size="page.pageSize"  layout="total, sizes, prev, pager, next" :total="page.total">
                        </el-pagination>
                    </el-col>
                </el-row>
            </el-drawer>
        </div>
        <!--补叫箱子抽屉-->
        <div>
            <el-drawer title="补叫缓存箱" size="50%" :visible.sync="addDrawer.drawer" :direction="addDrawer.direction" :before-close="handleClose">
                <el-button size="mini" type="primary" style="margin-bottom:3px;margin-left:3px" @click="addHcx">补叫箱子</el-button>
                <el-table :data="addDrawer.tableData" border height=550  @selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="50"></el-table-column>
                    <el-table-column type="index" width="50"></el-table-column>
                    <el-table-column property="workbinCode" label="箱子号" width="150" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column property="useLimitInfo" label="限用信息" width="180" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column property="itemCode" label="图号" width="180" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column property="qualityCode" label="质量编号" width="150" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column property="itemQty" label="数量" :show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="addQty" label="添加数量" resizable>
                    <template slot-scope="scope">
                        <input type="text" style="width:80px;" v-model="addDrawer.tableData[scope.$index].addQty"/>
                    </template>
                    </el-table-column>
                </el-table>
            </el-drawer>
        </div>
    </div>
</template>
<script>
import request from "@/utils/request.js";
export default {
    data(){
        return {
            hcxinfos:[],//扫码前显示的物料
            scanMaterialBoxs:[],//扫码确认后的物料
            toolCode:"",
            workbinCode:"",
            updateRemark:"",
            msAssginWorkbintoolRel:"",
            scanValue:"",//条码输入框值
            scanSave:false,//重复扫码保存
            scanHcxOper:false,//重复扫码缓存箱回库
            scanGzbOper:false,//重复扫码工作包回库
            scanMaterialOper:false,//重复扫码工作包回库
            fullscreenLoading: false,
            barcode:"",
            drawer:{
                drawer:false,
                direction:"rtl",
                leftdata:[],
                rightData:[]
            },
            drawer2:{
                drawer:false,
                direction:"rtl",
                materialTableData:[],
            },
            addDrawer:{
                drawer:false,
                direction:"rtl",
                tableData:[],
                selectData:[]
            },
            page:{
                total:1,
                pageSize:50,
                currentPage:1
            },
            workPackageInfo:{},
            loading:false,
            options:[{
                label:"带证",
                value:"Y"
            },{
                label:"不带证",
                value:"N"
            }],
            hcxbox:{
                dialog:{
                    dialogVisible:false
                }
            }
        }
    },
    methods:{
        handleClose(done){
            done();
        },
        handleClose2(done){
            done();
        },
        hxcDialogHandleClose(done){
            this.$confirm('确认关闭？').then(_ => {
                done();
            }).catch(_ => {});
        },
        openRemarkView(item){
            console.log('赋值',item)
            this.msAssginWorkbintoolRel = item.msAssginWorkbintoolRelId
            this.updateRemark = item.receiveRemark
            // this.toolCode = item.toolCode
            // this.workbinCode = item.workbinCode
            this.hcxbox.dialog.dialogVisible = true;
        },
        saveRemark(){
          
            console.log('测试2',this.hcxinfos[0].receiveRemark)
          request.post("/PointPackageSortRest/saveRemark",{"receiveRemark":this.updateRemark,"msAssginWorkbintoolRelId":this.msAssginWorkbintoolRel}).then((res)=>{
                
                if(res.data.retCode==200){
                    this.$Alert({title: "成功",message: res.data.message,type: "success"});
                   
                }else{
                    this.$Alert({title: "失败",message: res.data.message,type: "error"});
                }
                this.hcxbox.dialog.dialogVisible = false;
                this.scanValue = this.workbinCode;
                this.$options.methods.scan.bind(this)();

            });
        },
        handleCurrentChange(){

        },
        handleSizeChange(){

        },
        handleSelectionChange(val){
            this.addDrawer.selectData = val;
        },
        showWorkbinView(hcxinfo){
            this.addDrawer.drawer = true;
            console.log("hcxinfo",hcxinfo);
            this.addDrawer.tableData = [];
            request.post("/PointPackageSortRest/queryCanReplaceWorkbin",hcxinfo).then((res)=>{
                this.addDrawer.tableData = res.data;
            });
        },
        addHcx(){
            if(this.addDrawer.selectData.length!=1){
                this.$Alert({type:"error",message:"请选择一条记录!",title:"失败"});
                return ;
            }
            var addInfo = this.addDrawer.selectData[0];
            addInfo.toolCode = this.toolCode;
            request.post("/PointPackageSortRest/addHcx",addInfo).then((res)=>{
                console.log("res",res);
                this.$Alert({message:res.data.message,type:"info"});
                this.addDrawer.drawer = false;
                this.scanValue = this.workbinCode;
                this.$options.methods.scan.bind(this)();
            });
        },
        openReplaceView(value){
            this.drawer.drawer = true;
            this.drawer.leftdata = [];
            this.drawer.leftdata.push(value);
            console.log("value",value);
            this.drawer.rightData = [];
            //查询缓存箱子相同图号的其他物料
            request.post("/PointPackageSortRest/queryWorkbinMaterial",value).then((res)=>{
                console.log("rightres",res);
                this.drawer.rightData = res.data;
            });
        },
        saveReplaceData(){//保存替换的物料数据
            console.log("this.drawer.rightData",this.drawer.rightData);
            request.post("/PointPackageSortRest/replaceMatchInfo",{"sourceMatch":this.drawer.leftdata[0],"replaceMatchList":this.drawer.rightData}).then((res)=>{
                console.log("替换完成返回参数",res);
                if(res.data.retCode==200){
                    this.$Alert({title: "成功",message: res.data.message,type: "success"});
                    this.drawer.drawer = false;
                    this.scanValue = this.workbinCode;
                    this.$options.methods.scan.bind(this)();
                }else{
                    this.$Alert({title: "失败",message: res.data.message,type: "error"});
                }
            });
        },
        scan(){
            if(new RegExp("^212").test(this.scanValue)&&this.scanValue.length>=11){//扫码托盘
                this.$options.methods.showToolMatchMaterialInfo.bind(this)();
                this.scanValue="";
            }else if(new RegExp("^112").test(this.scanValue)){//扫码缓存箱子
                this.$options.methods.showHcxMatchMaterialInfo.bind(this)();
                this.scanValue="";
            }else if(new RegExp("^312").test(this.scanValue)){//扫码大件缓存箱子
                this.$options.methods.showHcxMatchMaterialInfo.bind(this)();
                this.scanValue="";
            }else if(this.scanValue=="9005"){//保存
                this.$options.methods.savePackage.bind(this)();
                this.scanValue="";
            }else if(this.scanValue=="9002"){//箱子回库
                this.scanHcxOper = false;
                this.$options.methods.workbinBack.bind(this)();
                this.scanValue="";
            }else if(this.scanValue=="9004"){//托盘回库
                this.scanGzbOper = false;
                this.$options.methods.toolBack.bind(this)();
                this.scanValue="";
            }else{//扫条码
                this.$options.methods.materailConfirm.bind(this)(); 
                this.scanValue="";
            }
        },
        //缓存箱扫码
        showHcxMatchMaterialInfo(){
            if(this.scanValue.length!=12){
                this.$Alert({title: "失败",message:"条码格式有误",type: "error"})
            }
            this.hcxinfos = [];
            this.scanMaterialBoxs = [];
            //页面缓存箱编码
            this.workbinCode = this.scanValue;
            if(this.toolCode==""){
                this.$Alert({title:"错误",type:"error",message:"请先扫托盘!"});
                return ;
            }
            //缓存箱扫码接口
            request.post("/PointPackageSortRest/searchInventoryMaterialByWorkbinCode",{workbinCode:this.workbinCode,toolCode:this.toolCode}).then((res)=>{
            // that.tableData = res.xxxxx
                console.log("res",res);
                if(res.data.retCode=='200'){
                    this.$Alert({
                    title: "成功",message: res.data.message,type: "success"
                    });
                    //页面进行赋值
                    this.hcxinfos = res.data.responseBody;
                }else{
                    this.$Alert({
                    title: "失败",message: res.data.message,type: "error",
                    });
                    this.workbinCode = "";
                };
            });  

            
        },
        showToolMatchMaterialInfo(){
            if(this.toolCode==""){
                if(this.scanValue.length!=12){
                    this.$Alert({
                    title: "失败",message:"条码格式有误",type: "error",
                    })
                }
                //页面托盘编码
                this.toolCode = this.scanValue;
            }else{//替换托盘时，清空物料
                this.toolCode = this.scanValue;
                this.scanMaterialBoxs = [];
                for(var i=0;i<this.hcxinfos.length;i++){
                    this.$refs.materialBox[i].style.color="black";
                    this.$refs.materialBox[i].innerHTML="未确认";
                }
                
            }
        },
        //分拣保存接口
        savePackage(){
            this.scanSave=false;
            if(this.workbinCode!="" && this.toolCode!=""){
                
                if(this.scanMaterialBoxs.length<1){
                    this.$Alert({
                    title: "失败",message: "请先确认物料",type: "error",
                    })
                }else{
                    this.loading = true;
                    //分拣保存接口
                    request.post("/materialReceipt/putToolPackage",{toolCode:this.toolCode,materialDTOs:this.scanMaterialBoxs}).then((res)=>{
                    console.log("res",res);
                    if(res.data.retCode=='200'){
                            this.$Alert({
                            title: "成功",message: res.data.message,type: "success"
                            })
                            this.scanSave=true;
                            this.hcxinfos = [];
                            this.scanMaterialBoxs = [];
                            this.loading = false;
                        }else{
                            this.$Alert({
                            title: "失败",message: res.data.message,type: "error"
                            })
                        }
                    }); 
                    //定时任务清楚
                    var loadingTime = setInterval(() => {
                        clearInterval(loadingTime);
                        this.scanSave=true;
                        this.hcxinfos = [];
                        this.scanMaterialBoxs = [];
                        this.loading = false;
                    }, 5000);

                }
            } else{
                this.$Alert({
                title: "失败",message: "请先扫缓存箱以及托盘",type: "error",
                })
            }
        },
        //缓存箱回库操作
        workbinBack(){
            if(this.workbinCode==""){
                this.$Alert({title: "失败", message: "请先扫缓存箱条码！",type: "error"});
                return ;
            }
            if(this.scanHcxOper){
                this.$Alert({title: "失败", message: "请不要重复扫缓存箱回库",type: "error"});
                return ;
            }
         /*   if(!this.scanSave){
                this.$Alert({title: "失败", message: "请先保存物料信息",type: "error"});
                return ;
            }*/
            //托盘扫码接口
            request.post("/inStoreroom/sortStoreRoomIn",{workbinCode:this.workbinCode}).then((res)=>{
               console.log("res",res);
               if(res.data.retCode=='200'){
                    //页面缓存箱编码
                    this.workbinCode = '';
                    this.scanHcxOper=true;
                    this.hcxinfos=[];
                    this.$Alert({
                    title: "成功",message: res.data.message,type: "success"
                    })
                }else{
                    this.$Alert({
                    title: "失败",message: res.data.message,type: "error",
                    })
                }
            });  
            
        },//工作包回库
        toolBack(){
            if(this.toolCode==""){
                this.$Alert({title: "失败", message: "请先扫工作包条码！",type: "error"});
                return ;
            }
            if(this.scanGzbOper){
                this.$Alert({title: "失败", message: "请不要重复扫托盘回库",type: "error"});
                return ;
            }
            if(!this.scanSave){
                this.$Alert({title: "失败", message: "请先保存物料信息",type: "error"});
                return ;
            }
            //托盘扫码接口
            request.post("/msTaskPackage/taskIn",{palletCode:this.toolCode}).then((res)=>{
               console.log("res",res);
               if(res.data.retCode=='200'){
                    //页面托盘编码
                    this.toolCode = '';
                    this.scanGzbOper=true;
                    this.scanMaterialBoxss=[];
                    this.$Alert({
                    title: "成功",message: res.data.message,type: "success"
                    })
                }else{
                    this.$Alert({
                    title: "失败",message: res.data.message,type: "error",
                    })
                }
            });  
            
        },
        //物料确认
        materailConfirm(){
            var barType = "";
            if(this.scanValue.includes('{')){
                var tiaomaObj = JSON.parse(this.scanValue);
                if(tiaomaObj.hasOwnProperty("CPHGZ")){//成品
                    this.barcode = tiaomaObj.CPHGZ;
                    barType = "CP";
                }else{//标件
                    this.barcode = tiaomaObj.CKCODE;
                    barType = "BZJ";
                }
            }else{
                this.barcode = this.scanValue;
                barType = "LJ";
            }
            if(barType!='BZJ'){
                for(let i=0;i<this.hcxinfos.length;i++){ 
                    if(this.barcode==this.hcxinfos[i].barcode){
                        console.log("barcode",i+"========="+this.hcxinfos[i].barcode);
                        if(this.scanMaterialBoxs.length>=1){
                            for(let j=0;j<this.scanMaterialBoxs.length;j++){
                                console.log("判断",this.hcxinfos[i].msAoMatchInfoId==this.scanMaterialBoxs[j].msAoMatchInfoId);
                                if(this.hcxinfos[i].msAoMatchInfoId==this.scanMaterialBoxs[j].msAoMatchInfoId){
                                    continue;
                                }else{
                                    this.$refs.materialBox[i].style.color="red";
                                    this.$refs.materialBox[i].innerHTML="已确认";
                                    this.hcxinfos[i].outQty=this.hcxinfos[i].matchQty;
                                    this.scanMaterialBoxs.push(this.hcxinfos[i]);
                                    this.$Alert({title: "成功", message: this.hcxinfos[i].barcode+"物料确认成功",type: "success"});
                                    break;
                                }
                            }
                        }else{
                            this.$refs.materialBox[i].style.color="red";
                            this.$refs.materialBox[i].innerHTML="已确认";
                            this.hcxinfos[i].outQty=this.hcxinfos[i].matchQty;
                            this.scanMaterialBoxs.push(this.hcxinfos[i]);
                            this.$Alert({title: "成功", message: this.hcxinfos[i].barcode+"物料确认成功",type: "success"});
                            break;
                        }              
                    }
                }
            }else{//标准件将所有的默认确认
                for(let i=0;i<this.hcxinfos.length;i++){
                    if(this.barcode==this.hcxinfos[i].barcode){
                        this.$refs.materialBox[i].style.color="red";
                        this.$refs.materialBox[i].innerHTML="已确认";
                        this.hcxinfos[i].outQty=this.hcxinfos[i].matchQty;
                        this.scanMaterialBoxs.push(this.hcxinfos[i]);
                        this.$Alert({title: "成功", message: this.hcxinfos[i].barcode+"AO下物料确认成功",type: "success"});
                    }
                }
                
            }    
        },
        //yebo 
        openRightWorkbinBox(index){
            this.$prompt('请输入缓存箱实际物料数量', '注意', {
                confirmButtonText: '保存',
                cancelButtonText: '取消'
            }).then(({ value }) => {
                console.log("val===",value);
                this.hcxinfos[index].rightQty = value;
                this.$options.methods.rightWorkbin.bind(this)(index);
            }).catch((e) => {console.log(e);this.$message({type: 'info',message: '取消输入'});});
        },
        rightWorkbin(index){
            console.log("index",index);
            for (let i = 0; i < this.hcxinfos.length; i++) {
                if (index == i) {
                    console.log("缓存箱表id",this.hcxinfos[i].msWorkbinMaterialId);
                    request.post("/materialReceipt/rightWorkbin",{data:this.hcxinfos[i]}).then((res)=>{
                        console.log(res);
                        if(res.data.retCode=='201'){
                            this.$Alert({ title: "失败", message: res.data.retMsg,type: "error"});
                        }else{
                            this.$Alert({title: "成功",message: res.data.retMsg,type: "success"});
                        }
                    })
                }
            }
        },
        searchMaterialInfo(){
            console.log("开始打印 workPackageInfo");
            console.log(this.workPackageInfo);
            var that = this;
            if(this.hcxinfos.length==0){
                this.$Alert({title:"提示",type:"error",message:"请扫缓存想"});
                return ;
            }
            this.drawer2.drawer = true;
            var msTaskPackageId = this.hcxinfos[0].msTaskPackageId;

            var queryParam = {
                packageId:this.workPackageInfo.msTaskPackageId,
                palletCode:this.toolCode,
                packageCode:this.workPackageInfo.packageCode,
                productCode:this.workPackageInfo.productCode,
                batchNo:this.workPackageInfo.batchNo,
                startPlaneNo:this.workPackageInfo.startPlaneNo,
                msTaskPackageId:msTaskPackageId
            };
            request.post("/MsAoMachInfo/selectMaterial",{"page":this.page,"queryParam":queryParam}).then((res)=>{
                console.log(res);
                that.drawer2.materialTableData = res.data.list;
                that.page.total = res.data.total;
            });
        },
    },
    mounted(){
        this.$bus.$on('sendWorkPackageInfoToWorkPackageSort',(e)=>{this.workPackageInfo = e})
    },
}
</script>

<style>
.pbox{
    padding:5px 0;
}
.box{
    /*border:1px solid rgb(52, 51, 51);*/
    border-radius: 8px;
    display: block;
    font-size: 1.1em;
    width:310px;
    padding:2px 3px;
    margin:5px 5px;
    float:left;
    box-shadow: 5px 5px 3px rgb(150, 146, 146);
}
.p-margin{
    margin-left:20px
}
</style>